<template>
	<view class='container bg-w'>
		<view class="header uni-flex uni-row flex-between">
			<uni-nav-bar title="工作计划">
				<template slot='left'>
					<view class="flex width-100">
						<i class='iconfont iconfanhui' @click='goBack()'></i>
					</view>
				</template>
			</uni-nav-bar>
		</view>
		<view class="position-r-top">
			<view class="buildList" v-if="auditData.length>0">
				<view class="project-total">共{{ total }}个人员</view>
				<view class="project-card" v-for="(item,index) in auditData" :key="index">
					<view class="project-card__head" @click="goToSubProjectInfo(item)">
						<view class="title">
							<text>{{ item.realName }}</text>
						</view>
						<text class="state" v-if="item.postType==0">施工员 </text>
						<text class="state" v-if="item.postType==1">审核员</text>
					</view>
					<view class="project-card__body">
						<view>
							<text>单位：{{ item.orgName }}</text>
						</view>
						<!-- <text>分组：{{ item.deptName }}</text> -->
					</view>
					<view class="project-card__foot"  @click="goToConstructionData(item)">
						<view>查看进度({{item.responsibleCount || 0}})</view>
					</view>
				</view>
			</view>
			<view class="nodata" v-else>
				<text>暂无数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { getWorkPlanList } from '@/common/api/WorkPlan.js'
	export default {
		data() {
			return {
				total: 0,
				auditData: [],
				page: {
					pageNo: 1,
					pageSize: 10,
				},
				totalPage:0,
				periodList:[],
			}
		},
		onLoad() {
			this.loadProductList();
		},
		methods: {
			goToSubProjectInfo() {
				
			},
			goToConstructionData(item) {
				uni.navigateTo({
					url: `/pages/Application/WorkPlan/WorkPlanDetail/WorkPlanDetail?postType=${item.postType}&userId=${item.userId}`
				})
			},
			loadProductList(){
				getWorkPlanList(this.page).then(res => {
					if(res.code == 20000){
						if(res.data){
							this.totalPage = res.data.pages;
							this.total = res.data.total
							this.auditData = this.auditData.concat(res.data.records)
						}
					}
				})
			},
			onReachBottom() { //上拉加载更多
				this.page.pageNo++
				if (this.page.pageNo <= this.totalPage) {
					this.loadProductList();
				}
			},
			onPullDownRefresh(){//下拉刷新
				this.page.pageNo = 1;
				this.auditData = [];
				this.loadProductList();
				setTimeout(function () {
						uni.stopPullDownRefresh();
				}, 1000);
			},
		}
	}
</script>

<style lang="less" scoped>
	.buildList{
		padding: 16rpx;
		background: #f9f9f9;
		.project-total{
			padding: 14rpx;
			text-align: center;
			color: #aaa;
		}
		.project-card{
			margin-bottom: 16rpx;
			color: #8C8C8C;
			border-radius: 10rpx;
			background: #fff;
			box-shadow: 0px 0px 5px rgba(0,0,0,.3);
			>.project-card__head{
				display: flex;
				height: 64rpx;
				line-height: 64rpx;
				color: #fff;
				background: #09AAE9;
				border-radius: 10rpx 10rpx 0 0;
				>.title{
					position: relative;
					flex: 1;
					padding: 0 20rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					>.uni-icons{
						position: absolute;
						right: 0;
						/deep/ span{
							font-size: 30rpx;
						}
					}
				}
				>.state{
					width: 140rpx;
					text-align: center;
				}
			}
			>.project-card__body{
				padding: 10rpx 20rpx 0;
				>view{
					display: flex;
					>text{
						display: block;
					}
				}
			}
			>.project-card__foot{
				display: flex;
				height: 72rpx;
				line-height: 72rpx;
				>view{
					width: 100%;
					text-align: center;
					color: #09AAE9;
				}
			}
		}
	}
</style>
